/*  File Name	: ChatService.h
 *  Author		: Javie Pong
 *	 E-mail		: 823960168@qq.com
 *  Created on	: 2012-10-4
 *  Description:
 */

#ifndef CHATSERVICE_H_
#define CHATSERVICE_H_
#include "Service.h"

class ChatMonitor;

class ChatService:public ServiceEX<ChatMonitor>
{
public:
		typedef ServiceEX<ChatMonitor> super;

public:
	ChatService(int p=0);

	virtual ~ChatService();

	virtual int open(void *p =0);

	virtual int handle_input(int  fd = INVALID_HANDLER);

	virtual int handle_output(int fd = INVALID_HANDLER);

	virtual int handle_timeout(void);

	virtual int handle_close(int handle = INVALID_HANDLER,
			ReactorMask mask= EventHandler::ALL_MASK);

	//int recycle(ChatService *s);

	virtual int recv_msg(const int limit_size = 1024*60);

	void reset(void);

	std::string name(void);

	const int role_id(void);

	void role_id(int role_id);

	int is_flash_sanbox(MessageBlock *mb);
private:
	int role_id_;
	long last_chat_time;
};

#endif /* CHATSERVICE_H_ */
